package com.cqut.forum.service.imp;

import java.util.List;
import java.util.Map;

import javax.annotation.Resource;

import org.springframework.stereotype.Controller;

import com.cqut.forum.dao.WallDao;
import com.cqut.forum.entity.FaceWall;
import com.cqut.forum.service.WallService;
import com.cqut.forum.util.MapKey;

@Controller
public class WallServiceImp implements WallService {

	@Resource
	private WallDao wallDao;
	@Override
	public FaceWall createWall(FaceWall wall) {
		wall = wallDao.save(wall);
		return wall;
	}
	@Override
	public List<Map<String, Object>> getWallByOption(int index, int size,
			String option) {
		List<Map<String, Object>> walls = wallDao.getWallByOption(index,size,option);
		return walls;
	}
	@Override
	public List<Map<String, Object>> loadWall(String wallOwner,
			String wallName, String publishTime, int index, int size) {
		List<Map<String, Object>> walls = wallDao.loadWall(wallOwner,wallName,publishTime,index,size);
		walls = MapKey.changeMapKey(walls);
		return walls;
	}
	@Override
	public FaceWall getByPictureAddress(String pictureAddress) {
		FaceWall faceWall = wallDao.getByPictureAddress(pictureAddress);
		return faceWall;
	}
	@Override
	public FaceWall delete(int wallId) {
		return wallDao.delete(wallId, FaceWall.class);
	}
	@Override
	public List<Map<String, Object>> getWall(int userId,int index,int size) {
		List<Map<String, Object>> walls = wallDao.getWall(userId,index,size);
		return MapKey.changeMapKey(walls);
	}
	@Override
	public int countWall(int userId) {
		int size = wallDao.countWall(userId);
		return size;
	}

}
